// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/dashboard',
    children: [
      // dashboard
      {
        path: '/dashboard',
        name: 'home',
        component: () => import('@/views/dashboard/Home'),
        meta: { title: '首页', keepAlive: true, icon: 'home', permission: ['dashboard'] }
      },
      {
        path: '/project',
        name: 'project',
        // redirect: '/form/base-form',
        component: () => import('@/views/project/ProjectList'),
        meta: { title: '项目维护', keepAlive: true, icon: 'flag', permission: ['form'] }
      },
      // forms
      {
        path: '/position',
        name: 'position',
        // redirect: '/form/base-form',
        component: () => import('@/views/location/Location'),
        meta: { title: '实时定位', keepAlive: true, icon: 'environment', permission: ['form'] }
      },
      {
        path: '/device',
        name: 'device',
        redirect: '/device/railList',
        component: RouteView,
        meta: { title: '设备维护', keepAlive: true, icon: 'control', permission: [] },
        children:[{
          path: '/device/railList',
          name: 'RailList',
          component: () => import('@/views/device/RailList'),
          meta: { title: '护栏管理', icon: 'bars', keepAlive: true }
        },{
          path: '/device/deviceList',
          name: 'DeviceList',
          component: () => import('@/views/device/DeviceList'),
          meta: { title: '设备管理', icon: 'mobile', keepAlive: true }
        },
        {
          path: '/device/deviceAlarmList',
          name: 'DeviceAlarmList',
          component: () => import('@/views/device/DeviceAlarmList'),
          meta: { title: '设备告警', icon: 'bell', keepAlive: true }
        }]
      },
      // {
      //   path: '/coordinate',
      //   name: 'coordinate',
      //   // redirect: '/form/base-form',
      //   component: () => import('@/views/form/basicForm'),
      //   meta: { title: '坐标维护', keepAlive: true, icon: bxAnaalyse, permission: ['form'] }
      // },
      {
        path: '/orgUser',
        name: 'orgUser',
        redirect: '/orgUser/orgList',
        component: RouteView,
        meta: { title: '用户管理', keepAlive: true, icon: 'deployment-unit'},
        children: [
          {
            path: '/orgUser/orgList',
            name: 'OrgList',
            component: () => import('@/views/orgUser/OrgList'),
            meta: { title: '单位管理', icon: 'apartment', keepAlive: true }
          },
          {
            path: '/orgUser/userList',
            name: 'UserList',
            component: () => import('@/views/orgUser/UserList'),
            meta: { title: '用户管理', icon: 'usergroup-add', keepAlive: true }
          }]
      },
      {
        path: '/system',
        name: 'system',
        redirect: '/system/setting',
        component: RouteView,
        meta: { title: '系统设置', keepAlive: true, icon: 'setting'},
        children: [
          {
            path: '/system/setting',
            name: 'accountSetting',
            component: () => import('@/views/system/settings/Index'),
            meta: { title: '个人中心', icon: 'user', keepAlive: true }
          }]
      }

      // other
      /*
      {
        path: '/other',
        name: 'otherPage',
        component: PageView,
        meta: { title: '其他组件', icon: 'slack', permission: [ 'dashboard' ] },
        redirect: '/other/icon-selector',
        children: [
          {
            path: '/other/icon-selector',
            name: 'TestIconSelect',
            component: () => import('@/views/other/IconSelectorView'),
            meta: { title: 'IconSelector', icon: 'tool', keepAlive: true, permission: [ 'dashboard' ] }
          },
          {
            path: '/other/list',
            component: RouteView,
            meta: { title: '业务布局', icon: 'layout', permission: [ 'support' ] },
            redirect: '/other/list/tree-list',
            children: [
              {
                path: '/other/list/tree-list',
                name: 'TreeList',
                component: () => import('@/views/other/TreeList'),
                meta: { title: '树目录表格', keepAlive: true }
              },
              {
                path: '/other/list/edit-table',
                name: 'EditList',
                component: () => import('@/views/other/TableInnerEditList'),
                meta: { title: '内联编辑表格', keepAlive: true }
              },
              {
                path: '/other/list/user-list',
                name: 'UserList',
                component: () => import('@/views/other/UserList'),
                meta: { title: '用户列表', keepAlive: true }
              },
              {
                path: '/other/list/role-list',
                name: 'RoleList',
                component: () => import('@/views/other/RoleList'),
                meta: { title: '角色列表', keepAlive: true }
              },
              {
                path: '/other/list/system-role',
                name: 'SystemRole',
                component: () => import('@/views/role/RoleList'),
                meta: { title: '角色列表2', keepAlive: true }
              },
              {
                path: '/other/list/permission-list',
                name: 'PermissionList',
                component: () => import('@/views/other/PermissionList'),
                meta: { title: '权限列表', keepAlive: true }
              }
            ]
          }
        ]
      }
      */
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
